package com.power.using.mydaggerp.ui.fragment.movie;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.power.using.mydaggerp.R;
import com.power.using.mydaggerp.base.fragment.BaseCompatFragment;
import com.power.using.mydaggerp.ui.fragment.movie.child.MovieFragment;

/**
 * Created by 聪明一只哈 on 2019/10/16.
 * Time: 2019/10/16  14:44
 */
public class MovieRootFragment extends BaseCompatFragment{

    public static MovieRootFragment newInstance() {
        Bundle args = new Bundle();
        MovieRootFragment fragment = new MovieRootFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_movie;
    }

    @Override
    public void initUI(View view, @Nullable Bundle savedInstanceState) {

        if (findChildFragment(MovieFragment.class) == null) {
            loadRootFragment(R.id.fl_container, MovieFragment.newInstance());
        }
    }

    @Override
    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
        super.onLazyInitView(savedInstanceState);
        //Logger.e("onLazyInitView");
        //加载子fragment
//        if (savedInstanceState == null) {
//            loadRootFragment(R.id.fl_container, MovieFragment.newInstance());
//        } else {  // 这里可能会出现该Fragment没被初始化时,就被强杀导致的没有load子Fragment
//            if (findChildFragment(MovieFragment.class) == null) {
//                loadRootFragment(R.id.fl_container, MovieFragment.newInstance());
//            }
//        }
    }
}
